Skip to content

feat: implement automatic Hyprland power-saving adjustments#1226

Open
CYKLER01 wants to merge 7 commits into
caelestia-dots:mainfrom
CYKLER01:feat/low-battery-optimization
Open

feat: implement automatic Hyprland power-saving adjustments#1226
CYKLER01 wants to merge 7 commits into
caelestia-dots:mainfrom
CYKLER01:feat/low-battery-optimization

Conversation

@CYKLER01
Copy link
Copy Markdown

@CYKLER01 CYKLER01 commented Feb 28, 2026

PR: Automated System Adjustments for Power Management

Overview

This PR implements a power management system that adjusts Hyprland decorations and monitor refresh rates based on the system's power profile and battery state. It integrates PowerProfiles with existing UI components to automate energy conservation on portable devices.

Key Changes

1. Logic & Triggers

The system now listens to multiple state changes to determine when to apply power-saving options:

  • Profile Switching: Detects transitions to the Power Saver profile.
  • Battery Thresholds: Allows for progressive setting changes as the battery drains (e.g., disabling specific effects at user-defined percentages).
  • Charging Status: Includes an "Evaluate thresholds" toggle that re-checks battery levels immediately upon disconnecting from AC power.
  • Hardware Detection: The Power section is dynamically hidden in the control panel if no battery is detected by the system.

2. Visual & Display Adjustments

  • Decoration Overrides: Toggles animations, blur, corner rounding, and shadows.
  • Three-Way State Control: Settings can be set to On, Off, or Unchanged. The "Unchanged" state ensures the logic does not override a user's current manual configuration during a profile switch.
  • Refresh Rate Throttling: Automatically fetches available monitor refresh rates. If a monitor is running above 60Hz, it is capped at 60Hz when power saving is active to reduce GPU and panel power draw.
  • Config Restoration: Automatically reloads the Hyprland configuration when switching away from Power Saver mode to return the environment to the user's defined defaults.

3. UI and User Feedback

  • Expandable Interface: Uses expandable cards to manage the increased number of settings without cluttering the main panel.
  • Notifications: Added toast notifications for low-power mode toggles.
  • Configuration: Added lowPowerModeChanged to UtilitiesConfig.qml to allow users to enable or disable these notifications.

Technical Implementation Details

  • BatteryMonitor.qml: Added a Connections block targeting the PowerProfiles service to monitor active_profile and charge changes.
  • Hyprland Integration: * Uses Hypr.extras.applyOptions for decoration-specific changes.
    • Uses Hypr.extras.message for executing monitor-specific commands and dispatching config reloads.
  • UtilitiesConfig.qml: Updated with the lowPowerModeChanged property to handle persistent user preferences for the new notification system.
  • Modular Logic: Logic for different triggers (thresholds vs. profiles) is separated to allow for fine-tuned control and easier maintenance as more triggers are added.

Credits

Huge thanks to @PixelKhaos since he almost entirely did the execution of this and for providing the demonstration video.

556607672-41140283-dd62-42e5-b25d-a6177c98967b.mp4

…ications based on power profile changes. including screen refresh rate.
@PixelKhaos
Copy link
Copy Markdown
Contributor

PixelKhaos commented Feb 28, 2026

Were you reading the discord? Just talked about this last night, funny timing haha

Instead of hooking onto the set profile, it might be better to read the battery level, with configurable levels, to allow setting the powerprofiles automatically.
Could set powersaving for example at 40%, and then disable effects and animations along with refreshrate throttle at 25% as a further stage of saving power.

But I do not think this should be something that changes with the power profile setting itself, rather battery or charging status dependent, that way it's a user configurable thing on top of controlling either manually when you don't want to change both on click.

@CYKLER01
Copy link
Copy Markdown
Author

CYKLER01 commented Feb 28, 2026

Were you reading the discord? Just talked about this last night, funny timing haha

nope, not even on the discord currently, i was in class when i wrote this becuase my battery kept draining too fast

Instead of hooking onto the set profile, it might be better to read the battery level, with configurable levels, to allow setting the powerprofiles automatically. Could set powersaving for example at 40%, and then disable effects and animations along with refreshrate throttle at 25% as a further stage of saving power.

But I do not think this should be something that changes with the power profile setting itself, rather battery or charging status dependent, that way it's a user configurable thing on top of controlling either manually when you don't want to change both on click.

I was also considering adding an option to the settings that allows the different battery optimizations to be toggled on or off as i know that not everyone wants this. Also different options for refresh rate settings in high power and battery saver.

@PixelKhaos
Copy link
Copy Markdown
Contributor

I was also considering adding an option to the settings that allows the different battery optimizations to be toggled on or off as i know that not everyone wants this. Also different options for refresh rate settings in high power and battery saver.

If you're fine with me jumping into the PR, I could try something and PR your forked branch with it?
My own laptop battery is aging so I do also want to have some better control over how and when things are set, I have a bit of a draft going already :)

@CYKLER01
Copy link
Copy Markdown
Author

CYKLER01 commented Feb 28, 2026

If you're fine with me jumping into the PR, I could try something and PR your forked branch with it? My own laptop battery is aging so I do also want to have some better control over how and when things are set, I have a bit of a draft going already :)

yep, that works fine for me. Im new to all of this so id appreciate some help in areas and I definitely need to optimize my battery as well as i only get about three hours.

@PixelKhaos
Copy link
Copy Markdown
Contributor

yep, that works fine for me. Im new to all of this so id appreciate some help in areas and I definitely need to optimize my battery as well as i only get about three hours.

Oh you didn't need to invite me to collaborate, I can PR your branch you used for this PR, better that way for separation, reviewing and merging. It'd simply update this PR too.
That said, I might take a bit, overscoped it a bit as I realized custom components were needed as I was testing.

PixelKhaos and others added 6 commits February 28, 2026 19:54
- Added three way toggle component
- Battery threshold-based power behaviour
- Charging/unplugged behavior
- Per-power profile settings
- Added power management UI pane
- Refresh rate control
- Changed battery pane to two-column layout (60/40)
- Threshold cards
  - Collapsible edit mode
- Fixed signal handlers
- Changed toggle colors
  - m3error for disable state
- Fixed duplicate charging toast
- Changed threshold grid to single-column list
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants